<%@page import="com.wenwu.common.utils.Uploader"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%
	request.setCharacterEncoding("utf-8");
	response.setCharacterEncoding("utf-8");
	request.setAttribute("fileBasePath", "http://localhost:1088");
	Uploader up = new Uploader(request);
	String flag = request.getParameter("flag");
	if (flag != null && flag.equals("head")) {
		up.setSavePath("D:/Relics/upload/head");//头像上传
	} else {
		up.setSavePath(up.getFolder("D:/Relics/upload/images"));
	}
	String[] fileType = { ".gif", ".png", ".jpg", ".jpeg", ".bmp" };
	up.setAllowFiles(fileType);
	up.setMaxSize(2048); //单位KB(2M)
	up.absoluteUpload();
	if (flag != null && flag.equals("head")) {//回写结果
		response.getWriter().print("<script type=\"text/javascript\">parent.callback(\""+up.getState()+"\",\""+up.getUrl()+"\");</script>");
	} else {
		response.getWriter().print(
				"{'original':'" + up.getOriginalName() + "','url':'"
						+ up.getUrl() + "','title':'"
						+ up.getOriginalName() + "','state':'"
						+ up.getState() + "'}");
	}
%>
